#include<iostream>
#include<cmath>
using namespace std;
const int N = 110;
int n, k, x;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		int x1, y1, x2, y2, x3, y3;
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		if (y1 == y2 && y3 == y2) {
			cout << 1 << endl;
			continue;
		}
		if (x1 == x2 && x3 == x2) {
			cout << 1 << endl;
			continue;
		}
		int k1 = max(x2, x3);
		int k2 = min(x2, x3);
		int k3 = max(y2, y3);
		int k4 = max(y2, y3);
		int ans = 0;
		if (k1 >= x1 && k2 <= x1) {
			if (k3 >= y1 && k4 <= y1) {
				cout << 1 << endl;
			}
			else {
				cout << min(abs(y1 - y2), abs(y1 - y3)) + 1 << endl;
			}
		}
		else{
			ans = min(abs(x1 - x2) + abs(y1 - y2), abs(x1 - x3) + abs(y1 - y3));
			cout << ans + 1 << endl;
		}
	}
	return 0;
}